<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../js/vue.js"></script>
    <script src="../js/dayjs.min.js"></script>
    <title>Document</title>
</head>

<body>
    <div id="root">
        <h2>当前的n值：{{n}}</h2>
        <h2>放大之后的n值：<span v-big="n"></span></h2>
        <button @click="n++"> 点击n+1</button>
    </div>
</body>
<script>
    Vue.config.productionTip = false
    const vm = new Vue({
        el: '#root',
        data: {
            n: 1
        },
        directives: {
            //指令与元素成功绑定的时候调用
            //指令所在的模板重新解析时
            big(element, binding) {
                element.innerText = binding.value * 10
            },
            fbind: {
                //指令与元素成功绑定时
                bind(element, binding) {
                    element.innerText = binding.value
                },
                //指令所在元素被插入页面时
                inserted(element, binding) {
                    element.focus()
                },
                //指令所在模板被重新解析时
                update(element, binding) {
                    element.innerText = binding.value
                    element.focus()
                }
            }
        },
    })
</script>

</html>